package com.youdianda.controller;

import com.youdianda.dto.YddLinkPageDTO;
import com.youdianda.entity.YddLink;
import com.youdianda.result.Result;
import com.youdianda.service.YddLinkService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/ydd_link")
@Api(tags = "友情链接管理")
public class YddLinkController {
    @Autowired
    protected YddLinkService yddLinkService;

    /**
     * 链接详情
     * @param id
     * @return
     */
    @GetMapping("/rowInfo")
    @ApiOperation(value = "链接详情")
    public Result rowInfo(String id){
        return yddLinkService.rowInfo(id);
    }

    /**
     * 链接修改
     * @param yddLink
     * @return
     */
    @PostMapping("/update")
    @ApiOperation(value = "链接修改")
    public Result update(@RequestBody YddLink yddLink){
        return yddLinkService.update(yddLink);
    }

    /**
     * 链接删除
     * @param id
     * @return
     */
    @GetMapping("/del")
    @ApiOperation(value = "链接删除")
    public Result del(String id){
        return yddLinkService.del(id);
    }

    /**
     * 链接添加
     * @param yddLink
     * @return
     */
    @PostMapping("/add")
    @ApiOperation(value = "链接添加")
    public Result add(@RequestBody YddLink yddLink){
        return yddLinkService.add(yddLink);
    }

    /**
     * 链接列表分页
     * @param dto
     * @return
     */
    @GetMapping("/list")
    @ApiOperation(value = "链接列表分页")
    public Result list(YddLinkPageDTO dto){
        return yddLinkService.list(dto);
    }

}
